package com.woniuxy.ssm.service.impl;

import com.woniuxy.ssm.bean.AdminBean;
import com.woniuxy.ssm.mapper.AdminMapper;
import com.woniuxy.ssm.service.IAdminService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author linke
 * @version 1.0
 * @className: AdminServiceImpl
 * @description: 管理员接口实现类
 * @date 2021/11/15 1:22
 */
@Transactional(readOnly = true)
@Service
public class AdminServiceImpl implements IAdminService {

    @Resource//自动注入
    private AdminMapper adminMapper;

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)//事务注解控制
    @Override
    public int saveAdminBean(AdminBean adminBean) {
        return adminMapper.saveAdminBean(adminBean);
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int updateAdminBean(AdminBean adminBean) {
        return adminMapper.updateAdminBean(adminBean);
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int deleteAdminBean(AdminBean adminBean) {
        return adminMapper.deleteAdminBean(adminBean);
    }

    @Override
    public AdminBean getOneById(Long id) {
        return adminMapper.getOneById(id);
    }
}